/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Connection;

import enteties.Album;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Trung Kien
 */
public class Arraylist {
    private String url;
    private String user;
    private String password;

    public Arraylist(String url, String user, String password) {
        this.url = url;
        this.user = user;
        this.password = password;
    }
    
     public List<Album> getAlbum(){
        List<Album> list = new ArrayList();
        try {
            Connection conn = ConnectionUtil.getConnection(url, user, password);
            CallableStatement cstmt = conn.prepareCall("{call ShowAlbum()}");
            ResultSet rs = cstmt.executeQuery();
            while(rs.next()){
                int id = rs.getInt(1);
                String albumname = rs.getString(2);
                String description = rs.getString(3);
                String datecreate = rs.getString(4);
                String username = rs.getString(5);
                
                Album a = new Album(albumname, description, datecreate, username);
                list.add(a);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
